/**
 * All function javascript call here
 */


/**
 * Submit from id with action
 * 
 * @param fromId
 * @param actionName
 */
function submitAction(fromId, actionName) {
	$("#" + fromId).attr('action', actionName);
	$("#" + fromId).attr('method', 'POST');
	$("#" + fromId).submit();
}

function callAjax_Sell() {
	var sAmount = $('#ammountSell').val();
	var sPricePer = $('#pricePerSell').val();
	
	$.ajax({
		type : 'POST',
		url : 'order/order-sell',
		cache : false,
		data : {
			action : 1,
			ammount: sAmount,
			pricePer : sPricePer
		},
		success : function (data) {
			console.log(data);
		}, error : function (errorData) {
			
		}
	});
}


function callAxjax_GetChangeData(symbol) {
	$.ajax({
		type : 'POST',
		url  : 'order/order-change-symbol',
		cache: true,
		data : {
			symbol : symbol
		},
		success : function (data) {
			
		}, error : function (errorData) {
			
		}
	});
}

function callAjax_Buy(){
	
}

function ex_calculate(a, b) {
	"buy" == a && (tr = "b");
	"sell" == a && (tr = "s");
	var c = $("#" + tr + "_btc").val(), d = $("#" + tr + "_price").val();
	$("#" + tr + "_loading").html(loadingnorm);
	$.post(_url("order"), {
		calculate : a,
		btc_count : c,
		btc_price : d,
		pair : b
	}, function(a) {
		$("#" + tr + "_all").html(a.all);
		$("#" + tr + "_fee").html(a.fee);
		$("#" + tr + "_comm").html(a.comm);
		"y" == a.error ? $("#" + tr + "_error").show() : $("#" + tr + "_error")
				.hide();
		$("#" + tr + "_loading").html("");
	}, "json");
}